/*
 * @lc app=leetcode.cn id=1021 lang=javascript
 *
 * [1021] 删除最外层的括号
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var removeOuterParentheses = function(s) {
   let count = 0;
   let res = '';
   for(let val of s) {
       if (val === '(' && count++ > 0) res += val;
       if (val === ')' && count-- > 1) res += val;
   }
   return res;
};
// @lc code=end

